﻿@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="e_box">
    <div class="move1">
    </div>
    <div class="e_box_register" id="user_register">
        @using (Html.BeginForm())
        {
            <table>
                <tbody>
                    @if (ViewBag.Recommended != null)
                    {
                        <tr>
                            <td class="l">
                                推荐人:
                            </td>
                            <td>
                                <input readonly type="text" value="@ViewBag.Recommended" />
                                <p>
                                    你注册游龙网帐号的推荐人</p>
                            </td>
                        </tr>
                    }
                    @*@if (ViewBag.Referrer != null)
                    {
                        <tr>
                            <td class="l">
                                Referrer:
                            </td>
                            <td>
                                <input readonly type="text" value="@ViewBag.Referrer" />
                                <p>
                                    Referrer</p>
                            </td>
                        </tr>
                    }*@
                    <tr>
                        <td class="l">
                            Email地址:
                        </td>
                        <td>
                            <input name="reg.email" id="txt_email" type="text" maxlength="80" />
                            <p>
                                此邮箱将作为您登录游龙网的帐号，并将用来接收验证邮件</p>
                        </td>
                    </tr>
                    <tr>
                        <td class="l">
                            设置用户名:
                        </td>
                        <td>
                            <input name="reg.alias" id="txt_alias" type="text" maxlength="30" />
                            <p>
                                用户名也可以作为您登录游龙网的帐号，大家以后就这样称呼您</p>
                        </td>
                    </tr>
                    <tr>
                        <td class="l">
                            设定密码:
                        </td>
                        <td>
                            <input name="reg.password" id="txt_password" type="password" maxlength="50" />
                            <p>
                                请输入您的帐号密码</p>
                        </td>
                    </tr>
                    <tr>
                        <td class="l">
                            确定密码:
                        </td>
                        <td>
                            <input id="txt_repassword" type="password" maxlength="50" />
                            <p>
                                请再输入一次您的密码</p>
                        </td>
                    </tr>
                    <tr>
                        <td class="l">
                            验证码:
                        </td>
                        <td>
                            <input name="reg.hip" id="txt_hip" class="verification" type="text" maxlength="4" />
                            <img id="validatecodeimg" src="@Url.Action("GetValidateCode", "Widget")" alt="hip code" title="看不清？点击换一张" />
                        </td>
                    </tr>
                </tbody>
            </table>
            <div class="refer">
                <span>
                    <label>
                        <input id="chk_eula" type="checkbox" />我已阅读并同意 <a href="/eula.html" target="_blank">
                            《游龙网交易条款》</a></label></span>
                <input id="btn_register" class="button" onmouseover="this.className='button_'" onmouseout="this.className='button'"
                    type="submit" value="" />
            </div>        
        }
        <script type="text/javascript">
            $(function () {

                /// $/user/register
                $("#user_register").each(function ($e) {

                    // validate elements before submit
                    var CheckForm = function () {

                        // email
                        if (!$.trim($("#txt_email", $e).val())) {
                            alert("请输入Email");
                            $("#txt_email", $e).focus();
                            return false;
                        }

                        // email
                        if (!$.trim($("#txt_email", $e).val())) {
                            alert("请输入准确格式的Email");
                            $("#txt_email", $e).focus();
                            return false;
                        }

                        // alias
                        if (!$.trim($("#txt_alias", $e).val())) {
                            alert("请输入用户名");
                            $("#txt_alias", $e).focus();
                            return false;
                        }

                        // password
                        if (!$("#txt_password", $e).val()) {
                            alert("请输入密码");
                            $("#txt_password", $e).focus();
                            return false;
                        }

                        // repassword
                        if (!$("#txt_repassword", $e).val()) {
                            alert("请再次输入密码");
                            $("#txt_repassword", $e).focus();
                            return false;
                        }

                        // check password
                        if ($("#txt_password", $e).val() != $("#txt_repassword", $e).val()) {
                            alert("两次密码输入不一致");
                            return false;
                        }

                        // hip
                        if (!$.trim($("#txt_hip", $e).val())) {
                            alert("请输入验证码");
                            $("#txt_hip", $e).focus();
                            return false;
                        }

                        // eula
                        if (!$("#chk_eula", $e).attr("checked")) {
                            alert("请阅读游龙网最终用户协议并遵守协议");
                            $("#chk_eula", $e).focus();
                            return false;
                        }

                        return true;
                    };

                    $("#btn_register", $e).click(function () {
                        return CheckForm();
                    });

                    // hip code
                    $("#validatecodeimg", $e).hip();

                });

            });
        </script>
    </div>
</div>
